package com.foxzzz.array;


public class Solution1006 {
    // */+-

    public int clumsy(int N) {
//        int res = N * (N - 1) / (N - 2) + (N - 3)
//                - (N - 4) * (N - 5) / (N - 6) + (N - 7);
        Integer res = 0;
        boolean isInit = true;
        int flag = 0;
        while (N - flag > 0) {
            int item = 0;
            if (N - flag >= 4) {
                item = (N - flag) * (N - flag - 1) / (N - flag - 2);
                res += N - flag - 3;
            } else if (N - flag == 3) {
                item = (N - flag) * (N - flag - 1) / (N - flag - 2);
            } else if (N - flag == 2) {
                item = (N - flag) * (N - flag - 1);
            } else if (N - flag == 1) {
                item = (N - flag);
            }
            flag += 4;
            if (isInit) {
                isInit = false;
                res += item;
            } else {
                res = res - item;
            }
        }

        return res;
    }

    public static void main(String[] args) {
        System.out.println(10 * 9 / 8 + 7 - 6 * 5 / 4 + 3 - 2 * 1);
//        System.out.println(new Solution1006().clumsy(10));
//        System.out.println(new Solution1006().clumsy(4));

    }
}
